package myjava.innerclassi;

public class Root4 {

   public static void main(String[] args) {

      /* anonymous inner classes */
      new Foo().meetFunPeople();
   }
}

class Foo {

   public void meetFunPeople() {

      // an anonimous class can:
      // - implement an inteface
      Enjoyable fabs = new Enjoyable() {

         public void smile() {
            System.out.println(":)");
         }

         public void laugh() {
            System.out.println("hahahaha");
         }
      };

      // - subclass another class (abstract or not)
      SouthAfrican andre = new SouthAfrican() {
         public void sayName() {
            System.out.println("Andre");
         }
      };

      fabs.smile();
      fabs.laugh();

      andre.sayHowzIt();
      andre.sayName();
   }
}

interface Enjoyable {

   public void smile();
   public void laugh();
}

abstract class SouthAfrican {

   public void sayHowzIt() {
      System.out.println("HOWZIT BRUUU!?");
   }

   abstract public void sayName();
}